<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">
<meta content="yes" name="apple-mobile-web-app-capable">
<meta content="black" name="apple-mobile-web-app-status-bar-style">
<meta content="telephone=no" name="format-detection">
<link rel="stylesheet" type="text/css" href="../static/easyui/themes/bootstrap/easyui.css">
<link rel="stylesheet" type="text/css" href="../static/easyui/themes/icon.css">
<link rel="stylesheet" href="../static/css/style-app.css" />
<script src="../static/jquery/jquery-1.12.4.js"></script>
<script src="../static/easyui/jquery.easyui.min.js"></script>
<script src="../static/easyui/locale/easyui-lang-zh_CN.js"></script>
<title>设备管理</title>
</head>

<body>
	<div class="top-part">
		<div class="header">
			<div class="return">
				<a href="javascript:history.go(-1);"></a>
			</div>
			<div class="header-title">设备管理</div>
		</div>
	</div>
	<div class="new-form">
		<div>
			<form id="ff" method="post">
				<table cellpadding="5" style="margin: auto;">
					<tr>
						<td style="width: 100px;">项目:</td>
						<td>
							<input style="width: 100%;" id="projectitem" name="projectitem" class="easyui-combobox"
								editable="false"
								data-options="
							    valueField: 'id',
							    textField: 'name',
							    url: '../projectitemlist.do?status=2',
							    onSelect: function(rec){
							    },panelHeight: 'auto'">
						</td>
					</tr>
					<tr>
						<td style="width: 100px;">名称：</td>
						<td colspan="3">
							<input class="easyui-textbox" id="name" name="name" style="width: 100%;" />
						</td>
					</tr>
					<tr>
						<td style="width: 100px;">开机维保时长（小时）：</td>
						<td>
							<input class="easyui-textbox" id="startinterval" name="startinterval"
								style="width: 100%;" />
						</td>
					</tr>
					<tr>
						<td style="width: 100px;">日常维保时长（天）：</td>
						<td>
							<input class="easyui-textbox" id="dailyinterval" name="dailyinterval"
								style="width: 100%;" />
						</td>
					</tr>
				</table>
			</form>
			<div style="text-align: center;" id="div1">
				<a href="#" class="d-btn btn-blue" onclick="savePro()">保存</a>
			</div>
		</div>
	</div>
</body>
<script th:inline="javascript">
	var currentPro = [[${equipment}]];

	$(document).ready(function() {
		if(currentPro != null){
			$("#projectitem").combobox("setValue", currentPro.item);
			$("#projectitem").combobox("disable");
			$("#name").textbox("setValue", currentPro.name);
			$("#startinterval").textbox("setValue", currentPro.startinterval);
			$("#dailyinterval").textbox("setValue", currentPro.dailyinterval);
		}else{
			currentPro = {};
		}
	});
	
	function savePro() {
		var projectitemid = $("#projectitem").combobox('getValue');
		currentPro.projectitemid = projectitemid;
		var name = $("#name").textbox('getValue');
		currentPro.name = name;
		var startinterval = $("#startinterval").textbox('getValue');
		currentPro.startinterval = startinterval;
		var dailyinterval = $("#dailyinterval").textbox('getValue');
		currentPro.dailyinterval = dailyinterval;
		$.ajax({
			type : 'POST',
			url : "../equipmentSave.do",
			data : JSON.stringify(currentPro),
			contentType : "application/json",
			success : function(data) {
				if (data.success){
					$.messager.alert('保存设备', '保存设备成功', 'success');
				}else{
					$.messager.alert('保存设备', '保存设备失败', 'error');
				}
				window.setInterval("window.location.href=document.referrer", 2000);
			},
			dataType : "json"
		});
	}
</script>
</html>